package com.suray.system.run.random.code.util;

public class NodePoint {
    private int x;

    private int y;

    public NodePoint(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public NodePoint upPoint() {
        if (x - 1 >= 0) {
            return new NodePoint(x - 1, y);
        }

        return null;
    }

    public NodePoint downPoint() {
        return new NodePoint(x + 1, y);
    }

    public NodePoint leftPoint() {
        if (y - 1 >= 0) {
            return new NodePoint(x, y - 1);
        }

        return null;
    }

    public NodePoint rightPoint() {
        return new NodePoint(x, y + 1);
    }

    @Override
    public String toString() {
        return "NodePoint{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}
